﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace RiskAlert_Tool
{
    
    internal class Tool
    {
        public static string PropertyToColumn(string prop)
        {
            char[] UpperLetter = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
            return prop.Insert(prop.LastIndexOfAny(UpperLetter), "_").ToLower();
        }
        public static string ColumnToProperty(string column)
        {
            List<char> chars = column.ToList();
            int num = 0;
            char first = chars[0];
            char last = chars[chars.IndexOf('_') + 1];
            num = Convert.ToInt32(first);
            num -= 32;
            first = Convert.ToChar(num);
            num = Convert.ToInt32(last);
            num -= 32;
            last = Convert.ToChar(num);
            chars.RemoveAt(0);
            chars.Insert(0, first);
            chars.RemoveAt(chars.IndexOf('_') + 1);
            chars.Insert(chars.IndexOf('_') + 1, last);
            chars.Remove('_');
            return chars.ToString();
        }
        public static string FormatCount(int count)
        {
            string result = count.ToString();
            while (result.Length < 5)
            {
                result = result.Insert(0, "0");
            }
            //else { throw new Exception(">EvidenceCount< 达到上限！"); }
            return result;
        }
        public static void OpenEvidence(string evidence_str)
        {
            ProcessStartInfo info = new ProcessStartInfo()
            {
                FileName = evidence_str,
                UseShellExecute = true,
            };
            Process.Start(info);
        }
    }
}
